#include <iostream>
using namespace std;
int p[102][102];
int main(){
	int n,s=0,c=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>p[i][j];
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(p[i][j]<=50){
				s++;
			}
			if(p[i][j]<=50 and (p[i-1][j]>50 or p[i+1][j]>50 or p[i][j-1]>50 or p[i][j+1]>50)){
				c++;
			}
		}
	}
	cout<<s<<" "<<c;
	return 0;
}
